<?php
/**
 * 获取患者列表--用于Android端的service同步数据
 * @authors Hex (hex@zpdchina.com)
 * @date    2017-03-09 15:17:02
 * @version $Id$
 */

class GethuanzhedatajsonController extends Yaf_Controller_Abstract {

    public function indexAction()
    {
        //获取参数
        $request = $this->getRequest();
        $yiyuan_id = $request->getPost('yiyuan_id',0);
        $user_department = $request->getPost('user_department','');
        $modify_time = $request->getPost('modify_time','');
//        if(empty($yiyuan_id))
//            Utility::apiJsonError(30001, '医院编号不能为空');
        if(empty($user_department))
            Utility::apiJsonError(30010, '科室不能为空');
        $patient_mdl = new PatientBasicInfoModel;
        $fields = 't.zhuangtai,t.zhuyuan_id,t.patient_id, t.zhenduan, t.hulijibie,t.zhuyuan_bingqu,t.bingchuang_fenzu, t.zhuzhenyishi, t.zerenhushi, t.ruyuan_riqi_time, t.ruyuan_qingkuang, t.yiliaofukuanfangshi, a.xingming, a.xingbie, a.nianling, a.shengri, t.his_display_zhuyuanhao, t.bingchuang_hao,a.chushengdi, b.gongzuo_dianhua, b.juzhu_dianhua, b.lianxiren_dianhua, t.blood_type, t.guominshi, t.zhusu,a.shenfenzheng_hao,t.chuyuan_riqi_time,t.modify_time,t.huanzhe_leixing,t.bingchuang_order';
        $patient_lists = CommonModel::getZhuyuanIdList($fields,$user_department,$yiyuan_id,$modify_time);
        $field_arr = $patient_mdl->_field_arr;
        $async_result = Utility::formatToSqlStrExtends($patient_lists, 'zhuyuan_basic_info', 'update_sql', $field_arr);
        $result["response_state"] = "true";
        $result["response_info"] = "数据同步成功:)";
        if(empty($async_result)){
            $result["update_sql"] = array();
        }else{
            $result["update_sql"] = $async_result;
        }
        $result["error"] = 200;
        $result["msg"] = "";
        Utility::apiJsonResultExtends($result);
    }

}